<template>
  <el-container class="home-container">
    <el-header>
      <div class="logo">
        <img src="../assets/future.png" alt="future.png" />
        <span>未来小组管理系统</span>
      </div>
      <div class="personal">
        <span class="hello">你好，欢迎***！</span>
        <img src="../assets/heading.png" alt="heading" class="heading" />
        <el-button plain>退出</el-button>
      </div>
    </el-header>
    <!-- 页面主要布局 -->
    <el-container class="maincontainer">
      <!-- 左侧导航栏 -->
      <!-- 根据是否折叠isCollapse这一属性的布尔值来动态显示侧边栏的宽度，为true代表折叠 -->
      <el-aside :width="isCollapse?'64px':'200px'">
        <div class="toggle" @click="ChangeWidth">|||</div>
        <el-menu
          default-active="2"
         
          background-color="#545c64"
          text-color="#fff"
        active-text-color="#409EFF"
        :unique-opened="true"
        :collapse="isCollapse"
        :collapse-transition="false"
        >
          <!-- 一级菜单 -->
          <el-submenu index="1">
            <!-- 一级菜单模板区 -->
            <template slot="title">
              <!-- 图标 -->
              <i class="el-icon-location"></i>
              <!-- 文本 -->
              <span>签到</span>
            </template>
            <!-- 二级菜单 -->
            <el-menu-item index="1-1">
              <!-- 二级菜单模板区 -->
              <template slot="title">
                <!-- 图标 -->
                <i class="el-icon-menu"></i>
                <!-- 文本 -->
                <span>1</span>
              </template>
            </el-menu-item>
            <el-menu-item index="1-2">
              <template slot="title">
                <!-- 图标 -->
                <i class="el-icon-menu"></i>
                <!-- 文本 -->
                <span>1</span>
              </template></el-menu-item>
            <el-menu-item index="1-3">
              <template slot="title">
                <!-- 图标 -->
                <i class="el-icon-menu"></i>
                <!-- 文本 -->
                <span>1</span>
              </template></el-menu-item>
          </el-submenu>
          <el-submenu index="2">
            <!-- 一级菜单模板区 -->
            <template slot="title">
              <!-- 图标 -->
              <i class="el-icon-film"></i>
              <!-- 文本 -->
              <span>课表</span>
            </template>
            <!-- 二级菜单 -->
          
            <el-menu-item index="1-2">
              <template slot="title">
                <!-- 图标 -->
               <i class="el-icon-menu"></i>
                <!-- 文本 -->
                <span><router-link  class="routera" to="/LeftSider/PersonalSchedule/All">个人课表</router-link> </span>
              </template></el-menu-item>
            <el-menu-item index="1-3">
              <template slot="title">
                <!-- 图标 -->
              <i class="el-icon-menu"></i>
                <!-- 文本 -->
                <span><router-link  class="routera" to="/LeftSider/CommunalSchedule">公共课表</router-link> </span>
              </template></el-menu-item>
          </el-submenu>
           <el-submenu index="3">
            <!-- 一级菜单模板区 -->
            <template slot="title">
              <!-- 图标 -->
              <i class="el-icon-document"></i>
              <!-- 文本 -->
              <span><router-link class="routera" to="/LeftSider/MeProcess">学习计划</router-link></span>
            </template>
            <!-- 二级菜单 -->
            <el-menu-item index="1-1">
              <!-- 二级菜单模板区 -->
              <template slot="title">
                <!-- 图标 -->
              <i class="el-icon-menu"></i>
                <!-- 文本 -->
                <span>1</span>
              </template>
            </el-menu-item>
            <el-menu-item index="1-2">
              <template slot="title">
                <!-- 图标 -->
                <i class="el-icon-menu"></i>
                <!-- 文本 -->
                <span>1</span>
              </template></el-menu-item>
            <el-menu-item index="1-3">
              <template slot="title">
                <!-- 图标 -->
               <i class="el-icon-menu"></i>
                <!-- 文本 -->
                <span>1</span>
              </template></el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <!-- 右边主要内容 -->
      <el-main>
        <!-- 面包屑导航区 -->
        <el-breadcrumb separator-class="el-icon-arrow-right">
  <el-breadcrumb-item v-for="(item,index) in $route.meta" :key="index">
    {{item}}
  </el-breadcrumb-item>
 </el-breadcrumb>
 

        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import cookie from "../utils/auth";
export default {
  name: "LeftSider",
  data() {
    return {
      key: false,
      // 左侧导航栏是否折叠,false代表不折叠
      isCollapse:false
    };
  },
  methods:{
    //点击|||，实现左侧菜单栏的展开和折叠
  ChangeWidth(){
this.isCollapse = !this.isCollapse;
}
  },
  mounted() {
    //进入前获取token，如果token没有则跳转页面
    let tokens = cookie.getToken("TokenKey");
    console.log(tokens);
    if (tokens != undefined) {
      this.key = true;
    }
  },
};
</script>

<style lang="less" scoped>
.routera {
  text-decoration: none;
  color: #ffffff;
}
.home-container {
  height: 100%;
}
.el-header {
  background: #373d41;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 0px;
  color: #fff;
  font-size: 18px;
}
.logo {
  display: flex;
  align-items: center;
  img {
    width: 78px;
    height: 60px;
  }
  span {
    margin-left: 10px;
  }
}
// .maincontainer {
//   width: 100%;
// }
.el-aside {
  width: 200px;
  background-color: #333744;
  .el-menu{
    border-right: none;
  }
}
.toggle{
color:#fff;
letter-spacing: 2px;
  text-align: center;
  line-height: 26px;
  font-size: 16px;
  cursor: pointer;
  background-color: #4a5064;
}
.el-main {
  background-color: #eaedf1;
}
@media screen and (max-width: 600px) {
  .hello {
    display: none;
  }
}
.personal {
  display: flex;
  align-items: center;
  .hello {
    margin-right: 80px;
    color: #fff;
    font-size: 16px;
  }
  @media screen and (max-width: 800px) {
    .heading {
      display: none;
    }
    .el-button {
      display: none;
    }
    .el-header{
        height: 60px;
        background: #373d41;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-left: 0px;
        color: #fff;
        font-size: 18px;
    }
    .logo{
        display: flex;
        align-items: center;
        img{
            width: 78px;
            height: 60px;
        }
        span{
            margin-left: 10px;
        }
    }
    .maincontainer{
        width: 100%;
    }
    .el-aside{
        width: 200px;
        background-color: #333744;
        @media (max-width:800px) {
            width: 0px !important;
        }
    }
    .el-main{
        background-color: #eaedf1;
    }
    @media screen and (max-width: 600px) {
        .hello{
            display: none;
        }
    }
    .personal{
        display: flex;
        align-items: center;
        .hello{
            margin-right: 80px;
            color: #fff;
            font-size: 16px;
        }
        @media screen and (max-width: 800px) {
            .heading{
            display: none;
            }
            .el-button{
            display: none;
            }
        }
        .heading{
            width: 50px;
            height: 50px;
            border-radius: 50%;
            margin-right: 80px;
        }
    }
    @media screen and (max-width: 200px) {
        .el-aside{
            width: 80px;
        }
    }
  }
  .heading {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-right: 80px;
  }
}
@media screen and (max-width: 200px) {
  .el-aside {
    width: 80px;
  }
}
.el-breadcrumb{
  margin-bottom: 15px;
  font-size: 12px;
}

</style>
